﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-2.1.3.min.js"></script>
    <script type="text/javascript" src="Scripts/jquery.autoSizeTextArea.js"></script>
    <script type="text/javascript">

        $.fn.autoSizeTextArea.defaults.onResize = function () {
            console.log($(this).height());
        };
        
        $.fn.autoSizeTextArea.defaults.onPasted = function () {
            console.log("Text pasted:\n");
            console.log($(this).val());
        };

        // Un-comment to update the textarea as soon as a key is released.
        //$.fn.autoSizeTextArea.defaults.keyupDelay = null;

        $(function () {
            $("#textarea1").autoSizeTextArea();
            $("#textarea2").autoSizeTextArea({ minHeight: 100 });
            $("#button1").click(function () {
                $("#textarea1").val("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
                               .autoSizeTextArea('update');
            });
            $("#button2").click(function () {
                $("#textarea1").autoSizeTextArea('destroy');
            });
        });
    </script>
</head>
<body>
    <p>The text area will auto-size when:</p>
    <ul>
        <li>You are typing and reach the width of the text area or press enter.</li>
        <li>You delete or back-space the text.</li>
        <li>You paste in some text.</li>
    </ul>
    <!--Don't use the 'cols' attribute on the textarea, use a style or class to specify a width-->
    <textarea id="textarea1" style="width:450px;"></textarea>
    <textarea id="textarea2" style="width:450px;height:100px;"></textarea>
    <p>
        <button id="button1">Copy text into first textarea</button>
        <button id="button2">Remove auto-size from first textarea</button>
    </p>
</body>
</html>
